home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_6.arc / WINDEV.ARC / WINAUX.C < prev    next >
C/C++ Source or Header  |  1989-02-07  |  2KB  |  113 lines

  1. /*
  2.  * Winaux main module
  3.  *
  4.  * Written by Bill Hall
  5.  * 3665  Benton Street, #66
  6.  * Santa Clara, CA 95051
  7.  *
  8.  * See Winaux.doc for usage information
  9.  *
  10.  */
  11.  
  12. #define NOCOMM
  13. #define NOKANJI
  14. #define NOMINMAX
  15. #include <io.h>
  16. #include <windows.h>
  17. #include <ttycls.h>
  18.  
  19. #define EXTERN
  20. #include "winaux.h"
  21.  
  22. /* entry point for windows */
  23. int FAR PASCAL WinMain(hInstance, hPrevInstance, lpszCmdLine, cmdShow)
  24. HANDLE hInstance, hPrevInstance;
  25. LPSTR lpszCmdLine;
  26. int cmdShow;
  27. {
  28.  
  29.     MSG msg;
  30.  
  31.     /* initialize program */
  32.     if (!InitProgram(hInstance,hPrevInstance, lpszCmdLine, cmdShow))
  33.       /* if we fail, then exit */
  34.     return FALSE;
  35.  
  36.     /* otherwise read messages until program is terminated by user */
  37.     while (GetMessage((LPMSG)&msg,NULL,0,0)) {
  38.     TranslateMessage((LPMSG)&msg);
  39.     DispatchMessage((LPMSG)&msg);
  40.     }
  41.     return msg.wParam;
  42. }
  43.  
  44. /* main window procedure */
  45. long FAR PASCAL MainWndProc(hWnd,message,wParam,lParam)
  46. HWND hWnd;
  47. unsigned message;
  48. WORD wParam;
  49. LONG lParam;
  50. {
  51.  
  52.     PAINTSTRUCT ps;
  53.     
  54.     switch(message) {
  55.  
  56.       /* adjust position of text display if window is resized */
  57.     case WM_SIZE:
  58.         AdjustHeight(LOWORD(lParam), HIWORD(lParam));
  59.         break;
  60.  
  61.       /* menu commands */
  62.     case WM_COMMAND:
  63.         WndCommand(hWnd, wParam);
  64.         break;
  65.  
  66.       /* display string from remote program */
  67.     case WM_USER:
  68.         if (!IsIconic(hWnd))
  69.             DispatchString(hWnd, wParam, lParam);
  70.         break;
  71.  
  72.       /* initialize some things when window is created */
  73.     case WM_CREATE:
  74.         WndCreate(hWnd,lParam);
  75.         break;
  76.  
  77.       /* quit */
  78.     case WM_DESTROY:
  79.         PostQuitMessage(0);
  80.         break;
  81.  
  82.       /* set window handle to null in win.ini when closing application */
  83.     case WM_CLOSE:
  84.         SetWinIni(NULL);
  85.         if (hFile)
  86.         close(hFile);
  87.         DestroyWindow(hWnd);
  88.         break;
  89.  
  90.       /* if closing Windows, set window handle to null in win.ini */
  91.     case WM_ENDSESSION:
  92.         if (wParam) {
  93.         if (hFile)
  94.             close(hFile);
  95.         SetWinIni(NULL);
  96.         }
  97.         break;
  98.  
  99.       /* refresh the window */
  100.     case WM_PAINT:
  101.         BeginPaint(hWnd, (LPPAINTSTRUCT)&ps);
  102.         MainWndPaint(hWnd, (LPPAINTSTRUCT)&ps);
  103.         EndPaint(hWnd, (LPPAINTSTRUCT)&ps);
  104.         break;
  105.  
  106.       /* all other messages are handled by windows */
  107.     default:
  108.         return ((long)DefWindowProc(hWnd,message,wParam,lParam));
  109.         break;
  110.     }
  111.     return(0L);
  112. }
  113.